Add tabsep, fix potential null deref on link text csv output, doc LAT_DIR, LON_DIR...
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 23 Sep 2003 13:39:53 +0000 (13:39 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 23 Sep 2003 13:39:53 +0000 (13:39 +0000)
gpsbabel/Makefile
gpsbabel/README
gpsbabel/csv_util.c
gpsbabel/internal_styles.c
gpsbabel/style/README.style
gpsbabel/style/tabsep.style [new file with mode: 0644]

index dbf92b10c15a3a54b5724237ac76365606b691db..e182b6c0fb5b88e5b432c583a0455fdc0c068611 100644 (file)
@@ -66,11 +66,11 @@ leaktest:
 
 dep:
        make clean && make CC="gcc -MMD"  && cat *.d */*.d > /tmp/dep && rm *.d */*.d
-       (echo -n "internal_styles.c: mkstyle.sh " ; echo style/*.style ; /bin/echo -e "\t./mkstyle.sh > $@ || (rm -f $@ ; exit 1)" ) >> /tmp/dep
+       (echo -n "internal_styles.c: mkstyle.sh " ; echo style/*.style ; /bin/echo -e '\t./mkstyle.sh > $@ || (rm -f $@ ; exit 1)' ) >> /tmp/dep
        echo Edit Makefile and bring in /tmp/dep
 
-VERSIONU=1_1_1_beta09042003
-VERSIOND=1.1.1_beta09042003
+VERSIONU=1_1_1_beta09232003
+VERSIOND=1.1.1_beta09232003
 release:
        ./chkdoc
        rm -fr gpsbabel-$(VERSIOND)
@@ -187,4 +187,4 @@ jeeps/gpsutil.o: jeeps/gpsutil.c jeeps/gps.h jeeps/gpsport.h \
   jeeps/gpsmath.h jeeps/gpsnmea.h jeeps/gpsmem.h jeeps/gpsrqst.h \
   jeeps/gpsinput.h jeeps/gpsproj.h jeeps/gpsnmeafmt.h jeeps/gpsnmeaget.h
 internal_styles.c: mkstyle.sh style/README.style style/arc.style style/csv.style style/custom.style style/dna.style style/fugawi.style style/gpsdrive.style style/gpsman.style style/mapconverter.style style/mxf.style style/nima.style style/ozi.style style/s_and_t.style style/xmap.style style/xmapwpt.style
-       ./mkstyle.sh > dep || (rm -f dep ; exit 1)
+       ./mkstyle.sh > $@ || (rm -f $@ ; exit 1)
index b0af83c6b65654982fb96b7be8117f3f398bf20b..898f6e0671985d803294c3cb79e97ce82bf68415 100644 (file)
@@ -385,6 +385,10 @@ THE FORMATS
        to text so it can be pulled into a spreadsheet or manipulated
        with text processing tools.
 
+    tabsep
+
+       Dumps all fields in a traditional Unix tab separated style.
+
     mapconverter
 
        Mapconverter is a format this is read by Mapopolis.com's mapconverter
index b07320932b33dc14f9dd7a93496df8ce720ae1a4..b87470b77b6be55f75eb01fd904733ebeabbaae2 100644 (file)
@@ -29,6 +29,7 @@
 /* macros */
 #define LAT_DIR(a) a < 0.0 ? 'S' : 'N'
 #define LON_DIR(a) a < 0.0 ? 'W' : 'E'
+#define NONULL(a) a ? a : ""
 
 /* convert excel time (days since 1900) to time_t and back again */
 #define EXCEL_TO_TIMET(a) ((a - 25569.0) * 86400.0)
@@ -681,10 +682,10 @@ xcsv_waypt_pr(const waypoint *wpt)
                strcpy(buff, "\"\"");
         } else
         if (strcmp(fmp->key, "URL_LINK_TEXT") == 0) {
-            sprintf(buff, fmp->printfc, wpt->url_link_text);
+            sprintf(buff, fmp->printfc, NONULL(wpt->url_link_text));
         } else
         if (strcmp(fmp->key, "ICON_DESCR") == 0) {
-            sprintf(buff, fmp->printfc, wpt->icon_descr);
+            sprintf(buff, fmp->printfc, NONULL(wpt->icon_descr));
         } else
 
         /* LATITUDE CONVERSION***********************************************/
index c60f91b74163e6fa0b982936f6735a782fe5f2c0..29b5b11eba8a8aaaffc2d68de9647ecea82fdb61 100644 (file)
@@ -456,6 +456,54 @@ static char s_and_t[] =
 "IFIELD        URL, \"\", \"%s\"                       # URL\n"
 "IFIELD        IGNORE, \"\", \"\"                      # Holder for Geocache Type\n"
 ;
+static char tabsep[] = 
+"# gpsbabel XCSV style file\n"
+"#\n"
+"# Format: Dumps all fields in a traditional Unix tab separated style\n"
+"#\n"
+"# The order of the fields (with the exception of LAT_DIR/LON_DIR) was\n"
+"# the same as documented in README.style when this format was created.\n"
+"# LAT_DIR/LON_DIR were undocumented, so I stuck them at the end of the\n"
+"# other lat/lon fields.\n"
+"#\n"
+"# However, please add any new gpsbabel fields to the end (to avoid\n"
+"# upsetting existing applications) regardless of where they land in\n"
+"# the README.style documentation.\n"
+"#\n"
+
+"DESCRIPTION           All database fields on one tab-separated line\n"
+
+"# FILE LAYOUT DEFINITIIONS:\n"
+"#\n"
+"FIELD_DELIMITER               TAB\n"
+"RECORD_DELIMITER      NEWLINE\n"
+"BADCHARS              TAB\n"
+
+"#\n"
+"# INDIVIDUAL DATA FIELDS:\n"
+"#\n"
+"IFIELD        INDEX, \"\", \"%d\"\n"
+"IFIELD        SHORTNAME, \"\", \"%s\"\n"
+"IFIELD        DESCRIPTION, \"\", \"%s\"\n"
+"IFIELD        NOTES, \"\", \"%s\"\n"
+"IFIELD        URL, \"\", \"%s\"               \n"
+"IFIELD        URL_LINK_TEXT, \"\", \"%s\"\n"
+"IFIELD        ICON_DESCR, \"\", \"%s\"\n"
+"IFIELD        LAT_DECIMAL, \"\", \"%f\"\n"
+"IFIELD        LON_DECIMAL, \"\", \"%f\"\n"
+"IFIELD        LAT_INT32DEG, \"\", \"%ld\"\n"
+"IFIELD        LON_INT32DEG, \"\", \"%ld\"\n"
+"IFIELD        LAT_DECIMALDIR, \"\", \"%f/%c\"\n"
+"IFIELD        LON_DECIMALDIR, \"\", \"%f/%c\"\n"
+"IFIELD        LAT_DIRDECIMAL, \"\", \"%c/%f\"\n"
+"IFIELD        LON_DIRDECIMAL, \"\", \"%c/%f\"\n"
+"IFIELD        LAT_DIR, \"\", \"%c\"\n"
+"IFIELD        LON_DIR, \"\", \"%c\"\n"
+"IFIELD        ALT_FEET, \"\", \"%fF\"\n"
+"IFIELD        ALT_METERS, \"\", \"%fM\"\n"
+"IFIELD        EXCEL_TIME, \"\", \"%f\"\n"
+"IFIELD        TIMET_TIME, \"\", \"%ld\"\n"
+;
 static char xmap[] = 
 "# gpsbabel XCSV style file\n"
 "#\n"
@@ -519,4 +567,4 @@ static char xmapwpt[] =
 "IFIELD        DESCRIPTION, \"\", \"%-.78s\"\n"
 ;
 #include "defs.h"
-style_vecs_t style_list[] = {{ "xmapwpt", xmapwpt } , { "xmap", xmap } , { "s_and_t", s_and_t } , { "ozi", ozi } , { "nima", nima } , { "mxf", mxf } , { "mapconverter", mapconverter } , { "gpsman", gpsman } , { "gpsdrive", gpsdrive } , { "fugawi", fugawi } , { "dna", dna } , { "custom", custom } , { "csv", csv } , { "arc", arc } ,  {0,0}};
+style_vecs_t style_list[] = {{ "xmapwpt", xmapwpt } , { "xmap", xmap } , { "tabsep", tabsep } , { "s_and_t", s_and_t } , { "ozi", ozi } , { "nima", nima } , { "mxf", mxf } , { "mapconverter", mapconverter } , { "gpsman", gpsman } , { "gpsdrive", gpsdrive } , { "fugawi", fugawi } , { "dna", dna } , { "custom", custom } , { "csv", csv } , { "arc", arc } ,  {0,0}};
index 4a3221cb3c09e50bea98e586daaea7ecadfd9f16..740f124d2c7b1e69bec32f416fd89d831984d40f 100644 (file)
@@ -256,6 +256,10 @@ The fields used by the XCSV parser are as follows:
  o LON_DECIMALDIR / LON_DIRDECIMAL
    Same as LAT_DECIMALDIR / LAT_DIRDECIMAL except LON_ defines LONGITUDE.
 
+ o LAT_DIR / LON_DIR
+   LAT_DIR returns the single character 'N' or 'S' depending on the 
+   hemisphere of the latitude.  LON_DIR returns 'E' or 'W' depending on
+   the hemisphere of the longitude.
 
  o ALT_FEET
    ALT_FEET is the position's ALTITUDE in FEET.  This value is treated as 
diff --git a/gpsbabel/style/tabsep.style b/gpsbabel/style/tabsep.style
new file mode 100644 (file)
index 0000000..0572dec
--- /dev/null
@@ -0,0 +1,46 @@
+# gpsbabel XCSV style file
+#
+# Format: Dumps all fields in a traditional Unix tab separated style
+#
+# The order of the fields (with the exception of LAT_DIR/LON_DIR) was
+# the same as documented in README.style when this format was created.
+# LAT_DIR/LON_DIR were undocumented, so I stuck them at the end of the
+# other lat/lon fields.
+#
+# However, please add any new gpsbabel fields to the end (to avoid
+# upsetting existing applications) regardless of where they land in
+# the README.style documentation.
+#
+
+DESCRIPTION            All database fields on one tab-separated line
+
+# FILE LAYOUT DEFINITIIONS:
+#
+FIELD_DELIMITER                TAB
+RECORD_DELIMITER       NEWLINE
+BADCHARS               TAB
+
+#
+# INDIVIDUAL DATA FIELDS:
+#
+IFIELD INDEX, "", "%d"
+IFIELD SHORTNAME, "", "%s"
+IFIELD DESCRIPTION, "", "%s"
+IFIELD NOTES, "", "%s"
+IFIELD URL, "", "%s"           
+IFIELD URL_LINK_TEXT, "", "%s"
+IFIELD ICON_DESCR, "", "%s"
+IFIELD LAT_DECIMAL, "", "%f"
+IFIELD LON_DECIMAL, "", "%f"
+IFIELD LAT_INT32DEG, "", "%ld"
+IFIELD LON_INT32DEG, "", "%ld"
+IFIELD LAT_DECIMALDIR, "", "%f/%c"
+IFIELD LON_DECIMALDIR, "", "%f/%c"
+IFIELD LAT_DIRDECIMAL, "", "%c/%f"
+IFIELD LON_DIRDECIMAL, "", "%c/%f"
+IFIELD LAT_DIR, "", "%c"
+IFIELD LON_DIR, "", "%c"
+IFIELD ALT_FEET, "", "%fF"
+IFIELD ALT_METERS, "", "%fM"
+IFIELD EXCEL_TIME, "", "%f"
+IFIELD TIMET_TIME, "", "%ld"